<form id="forma_dados_diversos">
    <table width="740">
<tr align="left">
            <td width="253">
                <a href="#" id="novoIrmao" >
                    <img id="addIrmao" src="<?php echo base_url() . 'assets/images/irmao.png' ?>" border="0" title="Irmao"  width="30" height="30"/></a>Adicionar Irm&atilde;o</td>
          <td width="719"></td>
      </tr>
    </table>

 
<br />
<?php 
    $exibeItem = (sizeof($irmaoList->getResult()) > 0) ? 'block' : 'none';
?>
<div align="left" id="div_irmao_list" style="display: <?= $exibeItem; ?>">
<fieldset style="width:auto;">
<legend style="size:auto; font-weight:bold; color:#333333">Im&atilde;os Matriculados</legend>
<br />
    <table width="82%" border="0" id="tbAluno" >
      <tr class="titulo" style="text-transform: uppercase;">
        <td width="20%"><div align="center">Matr&iacute;cula</div></td>
        <td colspan="2"><div align="center">Nome Irm&atilde;o</div></td>
      </tr>
<?php 
    foreach($irmaoList->getResult() as $irmao){
        
        $infoIrmao = $this->em->find('models\aluno',$irmao->getIrmaoId());
    
?>      
      <tr id="tr_irmao_<?= @$irmao->getIrmaoCod() ?>" style="background: #FFFFFF; ">
        <td><div align="center"><?= @$infoIrmao->getMatricula(); ?></div></td>
        <td width="80%"><?= utf8_encode(@$infoIrmao->getNome()); ?></td>
        <td>
            <a href="#" onclick="removeIrmao(<?= @$irmao->getIrmaoCod() ?>)">
                <img id="excIrmao" src="<?php echo base_url() . 'assets/images/excluir.png' ?>" border="0" title="Remover Irmao"/>            </a>        </td>
      </tr>
<?php
    }
?>  
</table>    
<br />
</fieldset>
</div> 
<input type="hidden" id="alunoIrmaoId" value="<?= $alunoId ?>" />
</form>
<script>
    $(document).ready(function(){
        
//        $('#fieldIrmao').hide();
        
         $('#addIrmao').click(function(){
             var alunoId = jQuery('input[id="alunoIrmaoId"]').val();
             jQuery.ajax( {
                type: "POST",
                url: '?c=c_aluno&m=addIrmao',
                cache: false,
                data:{alunoId:alunoId},
                beforeSend: function (){
                    $('#div_principal').addClass("div_carregando");
                },
                complete:  function(){
                    $('#div_principal').removeClass("div_carregando");
                },
                success: function(data){
                    jQuery.facebox(data);
                }
            });
             
//             $('#fieldIrmao').show();
             
         });
        
    });
    
    function lookupIrmao(matriculaIrmao,alunoId) {
        
        if(matriculaIrmao.length == 0) {
            // Hide the suggestion box.
            $('#suggestions').hide();
        } else {
            
            jQuery.ajax( {
                type: "POST",
                url: '?c=c_aluno&m=buscaIrmaoAutoComplete',
                cache: false,
                data: {queryString:matriculaIrmao,alunoId:alunoId},
                beforeSend: function (){
                    $('#div_body').addClass("div_carregando");
                },
                complete:  function(){
                    $('#div_body').removeClass("div_carregando");
                },
                success: function(data){
                    if(data.length >0) {
                        //$('#suggestions').show();
                        $('#dadosIrmao').html(data);
                    }
                }
            });

        }
    } 
    
    function fillIrmao(thisValue) {
        $('#matriculaIrmao').val(thisValue);
        setTimeout("$('#suggestions').hide();", 200);
    } 
  

    
</script>
